package com.drcoffee.drcoffeemall.mapper;

import com.drcoffee.drcoffeemall.entry.Attachment;
import com.drcoffee.drcoffeemall.entry.Cart;
import com.drcoffee.drcoffeemall.entry.ProductQuantity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ShoppingCartMapper {
    List<Attachment> getCart(String user_account, String search, String price_type, String language);

    List<Cart> getCartByattachment_id(@Param("user_account") String user_account, @Param("part_code") String part_code);

    boolean addToCart(Cart cart);

    boolean deletePartByCode(@Param("user_account") String user_account, @Param("part_code") List<String> part_code);

    boolean updateQuantityById(Cart cart);

    @Select("SELECT COUNT(*) FROM t_cart WHERE user_account = #{account}")
    Integer getCartsCount(String account);

    List<ProductQuantity> getCartByAccountAndPartCodes(String account, List<String> partCodes);

}
